var fdr;

/**
 * 设置结果接收对象
 * @param _opinionPrice
 */
function setModel(_fdr) {
    if (_fdr == undefined || !(_fdr instanceof com.jf.crawl.model.OpinionFdr)) {
        throw new java.lang.Exception("fdr 对象为空");
    }
    log.info("fdr {}", _fdr)
    fdr = _fdr;
}

function crawler() {
    //最新回购定盘利率
    var result = Get("http://www.chinamoney.com.cn/r/cms/www/chinamoney/data/currency/frr.json");
    var jsonObject = JSON.parseObject(result);
    if (jsonObject.containsKey("records")) {
        var jsonArray = jsonObject.getJSONArray("records");
        for (var i = 0; i < jsonArray.size(); i++) {
            jsonObject = jsonArray.getJSONObject(i);
            var name = jsonObject.getString("productCode");
            var price = jsonObject.getString("value");
            if (name == "FR001") {
                fdr.setFr001(commonUtil.string2Decimal(price));
            } else if (name == "FR007") {
                fdr.setFr007(commonUtil.string2Decimal(price));
            } else if (name == "FR014") {
                fdr.setFr014(commonUtil.string2Decimal(price));
            }
        }
    }
    //最新银银间回购定盘利率
    result = httpClient.Get("http://www.chinamoney.com.cn/r/cms/www/chinamoney/data/currency/fdr.json");
    jsonObject = JSON.parseObject(result);
    if (jsonObject.containsKey("records")) {
        var jsonArray = jsonObject.getJSONArray("records");
        for (var i = 0; i < jsonArray.size(); i++) {
            jsonObject = jsonArray.getJSONObject(i);
            var name = jsonObject.getString("productCode");
            var price = jsonObject.getString("value");
            if (name == "FDR001") {
                fdr.setFdr001(commonUtil.string2Decimal(price));
            } else if (name == "FDR007") {
                fdr.setFdr007(commonUtil.string2Decimal(price));
            } else if (name == "FDR014") {
                fdr.setFdr014(commonUtil.string2Decimal(price));
            }
        }

    }
    return true;
}